﻿using AutoMapper;
using DFGK_WMS.Context;
using DFGK_WMS.IRepository;
using DFGK_WMS.Model.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace DFGK_WMS.Repository
{
    /// <summary>
    /// agv设备信息
    /// </summary>
    public class TAgvmesgRepository: BaseRepository<TAgvmesg>, ITAgvmesgRepository
    {
        public TAgvmesgRepository(DFGK_DB context, IMapper mapper) : base(context, mapper)
        {
        }
        /// <summary>
        /// agv设备信息添加
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool AddAgvmesg(TAgvmesg msg)
        {
            Context.TAgvmegs.Add(msg);
            return Context.SaveChanges() > 0;
        }
        /// <summary>
        /// agv信息查询
        /// </summary>
        /// <param name="where"></param>
        /// <returns></returns>
        public TAgvmesg GetAgvmesg(Expression<Func<TAgvmesg,bool>> where)
        {
            return Context.TAgvmegs.Where(where).FirstOrDefault();
        }
        /// <summary>
        /// agv修改信息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool UpdateAgvmesg(TAgvmesg msg)
        {
            Context.TAgvmegs.Update(msg);
            return Context.SaveChanges() > 0;
        }
    }
}
